package lc.dfs;

import java.util.ArrayList;
import java.util.List;

/**
 * 字母大小写全排列
 *
 * @author yang
 * @date 2022/1/3
 */
public class 字母大小写全排列 {
    List<String> res = new ArrayList<>();

    public List<String> letterCasePermutation(String s) {
        dfs(s.toCharArray(), 0);
        return res;

    }

    private void dfs(char[] c, int u) {

        if (u == c.length) {
            StringBuilder sb = new StringBuilder();
            for (char a : c) {
                sb.append(a);
            }
            res.add(sb.toString());
            return;
        }
        dfs(c, u + 1);
        if (c[u] >= 'A') {
            c[u] ^= 32;
            dfs(c,u + 1);
        }
    }

}
